#include <iostream>
using namespace std;

#define int long long
const int R = 1e5 + 10;
int a[R];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, k, l, i, left, j, ans, cnt;
	cin >> n >> k >> l;
	for (i = 1; i <= n * k; ++i)
	{
		cin >> a[i];
	}
	sort(a + 1, a + n * k + 1);
	i = 1;
	while (a[i] - a[1] <= l)
	{
		++i;
	}
	--i;
	if (i < n)
	{
		cout << '0' << endl;
		return 0;
	}
	left = n * k - i;
	cnt = ans = 0;
	for (j = i; cnt <= n; --j)
	{
		if (left - k + 1 >= 0)
		{
			left -= k - 1;
			ans += a[j];
			++cnt;
		}
		else
		{
			break;
		}
	}
	j = 1;
	while (cnt < n)
	{
		ans += a[j];
		j += k; // 注意，是+=k！！！
		++cnt;
	}
	cout << ans << endl;
}
